package com.dq.domain.sys.user.user.centre;

import com.dq.domain.base.BaseEntity;
import com.dq.domain.sys.section.SysSection;
import com.dq.domain.sys.user.user.BossUser;
import com.dq.vo.baseVo.VO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @Author luchangtong
 * @Date 2020/5/9 17:12
 */
@Data
@Entity
@ApiModel("员工排班")
public class UserScheduling extends BaseEntity implements VO.ToVO{
    @ApiModelProperty("所属门店")
    @ManyToOne
    protected SysSection section;
    @ApiModelProperty("所属员工")
    @ManyToOne
    protected BossUser bossUser;

    @ApiModelProperty("年")
    @NotNull
    protected Long year;
    @ApiModelProperty("月")
    @NotNull
    protected Long month;
    @ApiModelProperty("日")
    @NotNull
    protected Long day;

    @ApiModelProperty("上班时间")
    protected String startTime;
    @ApiModelProperty("下班时间")
    protected String endTime;
    @ApiModelProperty("排班状态")
    @Enumerated(EnumType.ORDINAL)
    @Column(columnDefinition="int default 0")
    protected WorkStatus workStatus;

    @Transient
    protected Long id;
    @Transient
    protected Long userId;

    public enum WorkStatus{
        on("上班"),
        off("休息");

        public String name;

        WorkStatus(String name){
            this.name = name;
        }
    }

    @Data
    @ApiModel(value = "视图")
    public static class Vo implements VO {
        @ApiModelProperty("id")
        protected Long id;
        @ApiModelProperty("年")
        protected Long year;
        @ApiModelProperty("月")
        protected Long month;
        @ApiModelProperty("日")
        protected Long day;
        @ApiModelProperty("上班时间")
        protected String startTime;
        @ApiModelProperty("下班时间")
        protected String endTime;
        @ApiModelProperty("排班状态")
        protected String workStatusEn;
        @ApiModelProperty("排班状态")
        protected String workStatusCn;
        @ApiModelProperty("预约时间")
        protected String subsribeTime;

    }
    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.year = this.getYear();
        vo.month = this.getMonth();
        vo.day = this.getDay();
        vo.startTime = this.getStartTime();
        vo.endTime = this.getEndTime();
        vo.workStatusCn =this.getWorkStatus() != null ? this.getWorkStatus().name :"";
        vo.workStatusEn = this.getWorkStatus() != null ? this.getWorkStatus().toString():"";
        return vo;
    }
}
